﻿<?php
session_start();
include 'interface.php';
include 'records_table.php';

if (!isset($_SESSION['loggedIn']))
{
	$_SESSION['loggedIn'] = false;
}
$type = $_GET['type'];
if ($type != 1 && $type != 2)
{
	$type = 1;
}
echo "<title>";
  echo "Чатик - Главная страница";
echo "</title>";
echo "<html>";
    echo "<table width = \"100%\" bordercolor = \"green\"><!-- \"#5a009c\" -->";
        drawHeader();
    echo "<tr>";
        echo "<td></td>";
        echo "<td colspan = \"2\" rowspan = \"2\">";
        
        drawRecordsTable($type);                     
         /* if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'])
		 {
		 echo	$_SESSION['id'];
		echo	$_SESSION['name'];
		echo	$_SESSION['isAdmin'];     }
		else {
		echo "bla-bla-bla";
		}		 */
		echo "</td>";
        echo "<td>";
        echo "<table width = \"100%\">";
            echo "<tr>";
            echo "<td align = \"center\">";
            if ($_SESSION['loggedIn'])
            {
            	echo "<table width = \"100%\" bordercolor = \"red\">";

                echo "<tr><td align = \"center\"><p><b>";

				if ($_SESSION['isAdmin']) 
				{	
					echo "<a href = news.php>";

					echo "Добавить новость!</b></p></td></tr>";
					
				} else {
                echo "<a href = request.php>";

                echo "Оставить заявку!</b></p></td></tr>";
				}

            	echo "</table>";
            }
            echo "</td>";
            echo "</tr>";

            echo "<tr>";
            echo "<td align = \"center\">";
           /* if ($_SESSION['isAdmin'])
            {
            	echo "<table width = \"100%\" bordercolor = #5A009D>";

                echo "<tr><td align = \"center\"><p><b>";

                echo "<a href = admin.php>";

                echo "Администрирование</b></p></td></tr>";

            	echo "</table>";
            }*/
            echo "</td>";
            echo "</tr>";


        echo "</table>";
        echo "</td>";
        echo "</tr>";





    echo "</table>";    
echo "</html>";
?>
